package com.diaohaiwen.common.obj.page;

import com.alibaba.fastjson.JSON;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

import java.util.List;

/**
 * 分页数据返回
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
@Accessors(chain = true)
public class CurrentPageVo<T> {
    /**
     * 总数
     */
    private long total;
    /**
     * 数据集合
     */
    private List<T> records;

    public static <T> CurrentPageVo<T> create(long total, List<T> records) {
        return new CurrentPageVo<>(total, records);
    }

    @Override
    public String toString() {
        return JSON.toJSONString(this, true);
    }
}
